package hc.util

class Markdown2Html {
	
	public static void main(String[] args) throws IOException {
		
		File baseDir = new File("src/main/resources/static/docs");
		baseDir.eachFileRecurse { 
			if(it.isDirectory()) return;
			if(! it.getAbsolutePath().endsWith('.md')) return;
			
			String h5 = Markdown.generateHtml(it);
			
			String all = 
			"""<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
${h5}
	</body>
</html>"""
			
		String fileName = it.getAbsolutePath();
		fileName = fileName.substring(0, fileName.length()-3) + '.htm';
		hc.Util.fileWriteText(all, fileName);
		println "${fileName} is generated successfully." 
		}

	}
}
